package com.chenshu.transaction.controller;

import com.chenshu.transaction.model.LogInfo;
import com.chenshu.transaction.model.UserInfo;
import com.chenshu.transaction.service.LogService;
import com.chenshu.transaction.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created with IntelliJ IDEA
 * Description
 * User：chenshu
 * Date：2024-04-27
 * Time：14:37
 */
@RequestMapping("/propa")
@RestController
public class PropaController {
    @Autowired
    private LogService logService;

    @Autowired
    private UserService userService;

    @Transactional
    @RequestMapping("/p1")
    public String p1(UserInfo userInfo) {
        userService.insertUser(userInfo);
        LogInfo logInfo = new LogInfo();
        logInfo.setUsername(userInfo.getUsername());
        logInfo.setOp("用户主动注册");
        logService.insertLog(logInfo);
        return "注册成功";
    }
}
